package com.nidu.demo.tenant;

import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.nidu.demo.tenant.dto.TenantAddCmd;
import com.nidu.demo.tenant.dto.TenantListQry;
import com.nidu.demo.tenant.dto.TenantPageQry;
import com.nidu.demo.tenant.dto.TenantUpdateCmd;
import com.nidu.demo.common.enums.StatusEnum;
import com.nidu.demo.tenant.api.SysTenantService;
import com.nidu.demo.tenant.dto.*;
import com.nidu.demo.tenant.executor.command.TenantAddCmdExe;
import com.nidu.demo.tenant.executor.command.TenantDeleteCmdExe;
import com.nidu.demo.tenant.executor.command.TenantUpdateCmdExe;
import com.nidu.demo.tenant.executor.query.TenantListQryExe;
import com.nidu.demo.tenant.executor.query.TenantPageQryExe;
import com.nidu.demo.tenant.executor.query.TenantSingleQryExe;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * 租户服务实现类
 *
 * @author auto
 */
@Service
@RequiredArgsConstructor
public class SysTenantServiceImpl implements SysTenantService {

    private final TenantAddCmdExe addCmdExe;
    private final TenantUpdateCmdExe updateCmdExe;
    private final TenantDeleteCmdExe deleteCmdExe;
    private final TenantSingleQryExe singleQryExe;
    private final TenantListQryExe listQryExe;
    private final TenantPageQryExe pageQryExe;

    @Override
    public SingleResponse<TenantCO> add(TenantAddCmd cmd) {
        return addCmdExe.execute(cmd);
    }

    @Override
    public SingleResponse<TenantCO> update(TenantUpdateCmd cmd) {
        return updateCmdExe.execute(cmd);
    }

    @Override
    public Response delete(Long id) {
        return deleteCmdExe.execute(id);
    }

    @Override
    public Response delete(Set<Long> ids) {
        return deleteCmdExe.execute(ids);
    }

    @Override
    public SingleResponse<TenantCO> getById(Long id) {
        return singleQryExe.execute(id);
    }

    @Override
    public SingleResponse<TenantCO> getTenantByName(String name) {
        return singleQryExe.execute(name);
    }

    @Override
    public MultiResponse<TenantCO> list(TenantListQry qry) {
        return listQryExe.execute(qry);
    }

    @Override
    public PageResponse<TenantCO> page(TenantPageQry qry) {
        return pageQryExe.execute(qry);
    }

    @Override
    public Response updateStatus(Long id, StatusEnum status) {
        return updateCmdExe.updateStatus(id, status);
    }

} 